﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["goods"] = new List<string>();
            }
            if (Session["UserName"]==null)
            {
                this.Literal1.Text = "该用户没有登录请重新登录";

            }
            else
            {
                this.Literal1.Text = "欢迎您" + Session["UserName"].ToString() + "<br/>" ;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Session["UserName"]==null)
            {
                Response.Redirect("WebForm5.aspx");
            }
            else
            {
                List<string> list = (List<string>)Session["goods"];
                foreach (var item in form1.Controls)
                {
                    if (item is CheckBox)
                    {
                        CheckBox check = (CheckBox)item;
                        if (check.Checked)
                        {
                            list.Add(check.Text);
                        }
                    }
                }
                this.Button1.Text = "添加成功";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("WebForm4.aspx");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("WebForm5.aspx");
        }
    }
}